﻿using System;
using System.Text;

namespace DictationTool.ViewModel
{
    class HtmlBuilder
    {
        public HtmlBuilder(string title)
        {
            this.title = title;
        }

        public string HtmlContent
        {
            get
            {
                return String.Format("{0}{1}{2}", GenerateHeader(), contentBuilder, GenerateFooter()).Replace("\n","<br/>");
            }
        }

        public void Append(string title, string value)
        {
            contentBuilder.AppendFormat("<h4>{0}</h4><p>{1}</p><hr/>", title, value);
        }

        private StringBuilder GenerateHeader()
        {
            StringBuilder html = new StringBuilder("<html><body>");
            html.AppendFormat("<h1>{0}</h1><h3>{1}</h3><hr/>", title, DateTime.Now);
            return html;
        }

        private string GenerateFooter()
        {
            return string.Format("</body></html>");
        }

        private string title;
        private StringBuilder contentBuilder = new StringBuilder();
    }
}
